package Day43;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Creat with IntelliJ IDEA
 * Description
 * User: mamba24
 * Date: 2022-11-15
 * Time: 9:25
 * To BE A Better Person-2020-3-2
 */
public class TestDemo {
    private static boolean containString(String s,String[] strings){
        for (int i = 0; i < strings.length; i++) {
            if(s.equals(strings[i])){
                return true;
            }
        }
        return false;
    }
    private static char convert(char c){
        switch (c){
            case 'A':
            case 'B':
            case 'C':
                return '2';
            case 'D':
            case 'E':
            case 'F':
                return '3';
            case 'G':
            case 'H':
            case 'I':
                return '4';
            case 'J':
            case 'K':
            case 'L':
                return '5';
            case 'M':
            case 'N':
            case 'O':
                return '6';
            case 'P':
            case 'Q':
            case 'R':
            case 'S':
                return '7';
            case 'T':
            case 'U':
            case 'V':
                return '8';
            case 'W':
            case 'X':
            case 'Y':
            case 'Z':
                return '9';

        }
        return '0';
    }
    private static String convertString(String s){

        char[] temp=new char[s.length()+1];
        int temp_index=0;
        int len=0;
        for (int i = 0; i < s.length(); i++) {
            if(temp_index == 3){
                temp[3]='-';
                temp_index++;
                i--;
                continue;
            }
            if(s.charAt(i) == '-'){
                continue;
            }
            if(s.charAt(i)>=65 && s.charAt(i)<=90){
                //大写字母
                char c=convert(s.charAt(i));
                temp[temp_index]=c;
            }else if (s.charAt(i)>=48&&s.charAt(i)<=57){
                //数字
                temp[temp_index]=s.charAt(i);

            }
            temp_index++;
        }
        for (int i=0;i < temp.length;i++){
            if(temp[len]!=0){
                len++;
            }else{
                break;
            }
        }
        char[] ret=new char[len];
        for(int i=0;i<len;i++){
            ret[i]=temp[i];
        }
        return new String(ret);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int num=sc.nextInt();
            String[] strings=new String[num];
            int index=0;
            while (num >0){
                String temp=sc.next();

                //转换为号码串
                String ret=convertString(temp);
                //判断是否存在相同号码
                if(!containString(ret,strings)){
                    strings[index]=ret;
                    index++;
            }

                num--;

            }
            //输出字符串内容
            Arrays.sort(strings);
            for (int i=0;i< strings.length;i++){
                if(strings[i]!=null){
                    System.out.println(strings[i]);
                }


            }
        }
    }
}
